extends "enemy.gd"

@export var max_hp = 8
@export var speed = 15
var direction

var detect
var sprite 

func getDamageType():
	return "hurtful"

func _ready():
	super._ready()
	sprite = get_node("Sprite")
	detect = get_node("Detect")
	hp = max_hp
	direction = -1 + 2*(randi() % 2)
	sprite.scale.x = direction

func _physics_process(delta):
	move_and_collide(Vector2(direction * speed * delta, 0))

func _on_Detect_body_enter( body ):
	direction *= -1
	sprite.scale.x = direction
